<?php
namespace app\admin\logic;


use app\admin\model\Gcategory;

class Gcategorylogic
{
    // 拼装查询条件
    public static function reformData($param)
    {
        // 判断是否传parent_id值,默认值给0
        $parent_id = isset($param['parent_id'])?$param['parent_id']:0;

        $where[]=['parent_id','=',$parent_id];
        return $where;
    }

    // 增加next_cate字段 用于判断是否可以点击下一个分类
    public static function setCateNext($sel)
    {
        $parent_id_all = Gcategory::getParentIdAll();
        // array_unique 删除重复的值
        $parent_id_all=array_unique($parent_id_all);
        foreach ($sel as &$vo){
            if (in_array($vo['cate_id'],$parent_id_all)){
                $vo['next_cate']=1;
            }
        }
        return $sel;
    }

}




?>
